home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15367 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.cern.ch!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: May fprintf () be recursive?
  5. Date: 18 Apr 96 17:23:31 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.829848211@news.cern.ch>
  8. References: <4l5f9s$ad3@news.cs.tu-berlin.de>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=US-ASCII
  12. Content-Transfer-Encoding: 7bit
  13. X-Newsreader: NN version 6.5.0 #18 (NOV)
  14.  
  15. In <4l5f9s$ad3@news.cs.tu-berlin.de> ulrich@cs.tu-berlin.de (Ulrich Wittenberg) writes:
  16.  
  17. >My program developed a strange error in the dynamic memory management
  18. >when it had a line of the following type in it:
  19. >
  20. >fprintf (stderr, "fprintf returns %#X\n", fprintf (stderr, "TEST\n"));
  21. >
  22. >So, my question is: Is it allowed for fprintf to be called
  23. >recursively????
  24.  
  25. fprintf is _not_ called recursively in this example.  The inner fprintf
  26. call will return before the outer fprintf will be called.  Your usage
  27. is perfectly OK.  Only the fprintf function could call itself recursively,
  28. you can't do that (no matter how hard you try :-)
  29.  
  30. >BTW: when I changed that line to an iterative way, the program worked
  31. >fine
  32. >
  33. >Suggestions?
  34.  
  35. 1. There is a bug in your compiler (not very likely).
  36.  
  37. 2. There is a bug somewhere else in your code and this construct simply
  38.    exposes it.  Consider yourself lucky and try to find the real bug.
  39.  
  40. 3. If you insist that your code is bug free, try to write a minimal
  41.    (but complete) example that illustrates your problem and post it here.
  42.  
  43. Dan
  44. --
  45. Dan Pop
  46. CERN, CN Division
  47. Email: danpop@mail.cern.ch 
  48. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  49.